package com.jie.component.lock.annotion;

import com.jie.component.lock.core.LockType;
import com.jie.component.lock.strategy.LockTimeOutStrategy;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;

/**
 * @author jie
 * @version 1.0 2025-02-10 业务锁注解
 */
@Target(value= {ElementType.TYPE, ElementType.METHOD})
@Retention(value= RetentionPolicy.RUNTIME)
public @interface ServiceLock {
    /**
     * 锁的类型，默认可重入锁
     */
    LockType lockType() default LockType.Reentrant;

    /**
     * 业务名称
     * @return
     */
    String name() default "";

    /**
     * 自定义业务key
     * @return
     */
    String[] keys();

    /**
     * 尝试加锁失败最多等待时间
     * @return
     */
    long waitTime() default 10;

    TimeUnit timeUnit() default TimeUnit.SECONDS;

    /**
     * 加锁超时的处理策略
     * @return
     */
    LockTimeOutStrategy lockTimeoutStrategy() default LockTimeOutStrategy.FAIL;

    /**
     * 自定义的加锁超时处理策略
     * @return
     */
    String customLockTimeoutStrategy() default "";
}
